package com.waiting.string;

/**
 * @desctiption
 * @Author bjweitingting
 * @date 2018/5/4
 **/
public class Main {
    public static final String format = "{ \"index\" : {\"_index\": %s, \"_type\": %s,\"_id\" : %s } }\n";// 有则覆盖
//    public static final String format = "indx.%s.type:%s,id:%s";// 有则覆盖

    public static void main(String[] args) {
        String test = "20180508151357rc3fa3ad603516ec572e2278828ddb3e5\nstartTime=1522512000000,endTime=1525190400000";
//        test="{\"autoReply\":1,\"from\":0,\"id\":2469654036,\"mType\":1,\"msg\":\"您好，请问有什么可以帮助您？如需人工服务请点击右上角的“人工客服”按钮哦~\",\"sessionId\":423098113,\"staffId\":-146900,\"time\":1525796781759,\"userId\":1067875614}";
//        splitString(test,"startTime");
//        test = "{\"autoReply\":1,\"from\":0,\"id\":2469654036,\"mType\":1,\"msg\":\"您好，请问有什么可以帮助您？如需人工服务请点击右上角的“人工客服”按钮哦~\",\"sessionId\":423098113,\"staffId\":-146900,\"time\":1525796781759,\"userId\":1067875614}";
//        System.out.println(subString(test).replace("\n",","));
//        test="{\"autoReply\":1,\"from\":0,\"id\":2469654036,\"mType\":1,\"msg\":\"您好，请问有什么可以帮助您？如需人工服务请点击右上角的“人工客服”按钮哦~\",\"sessionId\":423098113,\"staffId\":-146900,\"time\":1525796781759,\"userId\":1067875614}\n" +
//                "{\"autoReply\":1,\"from\":0,\"id\":2469666846,\"mType\":1,\"msg\":\"您好，请问有什么可以帮助您？如需人工服务请点击右上角的“人工客服”按钮哦~\",\"sessionId\":423091971,\"staffId\":-146900,\"time\":1525798024749,\"userId\":988794269}";
//        System.out.println(test.replace("\n", ","));
//        stringFormat();
        String trinTest = " trim ";
        System.out.println("开始" + trinTest.trim() + "结尾");
    }
    public static String testJson="{\"test\":\"result\"}";
    public static String quetionFormat = "{\"query\": {\"bool\": {\"must\": [{\"match\": {\"from\": \"1\"}},{\"match\": {\"mType\": \"1\"}},{\"range\": {\"staffId\": {\"gte\": 10}}},{\"terms\": {\"msg\": [%s]}}]}}}\n";

    //字符串格式化
    public static String stringFormat() {
//        return String.format(format, tmp);
//        return String.format(format, "index", "type", "id");

        System.out.println(String.format(quetionFormat, "\"如何\", \"怎么\",\"哪里\",\"？\",\"为什么\""));
        return "";
    }

    public static String subString(String tmp) {
        int indexStart = tmp.indexOf("startTime=");
        System.out.println(indexStart);
        //字符串截断
        return tmp.substring(0, indexStart - 1);
    }

    //字符串分割
    public static void splitString(String tmp, String seplator) {
        String[] result = tmp.split(seplator);
        for (int i = 0; i < result.length; i++) {
            System.out.println(result[i]);
        }
        if (true) {
            System.out.println(tmp);
        }
    }
}
